/**
 * Project Name:fastPlat
 * File Name:ArticleCommentServiceImpl.java
 * Package Name:com.fast.cms.service.article.impl
 * Date:2014年12月17日下午1:50:30
 * Copyright (c) 2014, lsflu@126.com All Rights Reserved.
 *
*/

package com.fast.cms.service.article.impl;

import org.springframework.stereotype.Service;

import com.fast.base.dao.daoSuport.JpaDaoSupport;
import com.fast.base.db.page.PageView;
import com.fast.base.db.page.QueryResult;
import com.fast.cms.model.article.ArticleComment;
import com.fast.cms.service.article.ArticleCommentService;
import com.fast.cms.web.form.ArticleCommentForm;

/**
 * ClassName:ArticleCommentServiceImpl <br/>
 * 用途: 文章评论服务 <br/>
 * 开发人员：lushuifa  http://lushuifa.iteye.com/
 * 邮箱:lsflu@126.com
 * @version  
 * @since    JDK 1.6
 * @see
 * Date:     2014年12月17日 下午1:50:30 <br/> 	 
 */
@Service("articleCommentService")
public class ArticleCommentServiceImpl extends JpaDaoSupport implements
		ArticleCommentService {
	
	/**
	 * 分页获取评列表
	 * @param articleCommentForm
	 * @return
	 */
	@Override
	public PageView<ArticleComment> getArticleCommentListByPage(ArticleCommentForm articleCommentForm) {
		int page = articleCommentForm.getPage();//当前页
  		int pagesize = articleCommentForm.getRows();//每页面显示多少条
  		String deleteFlag = articleCommentForm.getDeleteFlag();
  		String isView = articleCommentForm.getIsView();
		StringBuffer sb = new StringBuffer(" where 1=1 ");
		
		if(!deleteFlag.equals("")){
			sb.append("and delete_flag="+deleteFlag+" ");
		}else{
			//默认查询未回收的数据
			sb.append("and delete_flag=0 ");
		}
		
		if(!isView.equals("")){
			sb.append("and isView="+isView+" ");
		}else{
			//默认查询
			sb.append("and isView=0 ");
		}
		String ordersql = " order by edit_time desc ";
		QueryResult<ArticleComment>  queryResult = super.queryForBeanListByPage(ArticleComment.class,sb.toString(),ordersql,(page-1)*pagesize,pagesize);
		PageView<ArticleComment> pageView = new PageView<ArticleComment>();
	    pageView.setCurrentPage(page);
		pageView.setQueryResult(queryResult);
 		return pageView;
	}

}

